<template>
  <div>
    <h1>鉴定结果</h1>
    <el-alert
      v-if="del_success===1"
      title="删除成功"
      type="success">
    </el-alert>
    <div>
      <el-row :gutter="20">
        <el-col :span="18"><div>
          <el-radio-group v-model="radio1">
            <el-radio-button label="报表编号"></el-radio-button>
          </el-radio-group>
        </div></el-col>
        <el-col :span="3"><div>
          <el-button type="text" @click="this.add">添加鉴定结果</el-button>
        </div></el-col>
        <el-col :span="1"><div>
          <el-button type="text" @click="this.selectinfo">清空检索</el-button>
        </div></el-col>
      </el-row>
    </div>
    <el-input v-model="userinfo" placeholder="请输入信息"></el-input>
    <el-button type="primary"
               style="width: 100%;margin-top: 20px; margin-bottom: 30px; border-radius:0px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)"
               class="el-icon-search" @click="select">检索</el-button>
    <el-table
      :data="info1"
      height="360"
      v-loading="loading"
      border
      style="width: 100%">
      <el-table-column
        prop="bid"
        label="报表编号"
        align="center"
        width="200"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="jid"
        label="鉴定机构编号"
        align="center"
        width="200"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="rtext"
        label="鉴定结果描述"
        align="center"
        width="350"
        :resizable="false">
      </el-table-column>
      <el-table-column
        prop="providedate"
        label="结果生成日期"
        align="center"
        width="350"
        :resizable="false">
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "IdentifyList" ,
  data(){
    return {
      id: '',
      radio1: '报表编号',
      userinfo: '',
      del_success:'',
      info1:[],
      info:{
        wid:'1'
      },
      loading: true,
    }
  },
  beforeRouteEnter: (to, from, next) => {
    console.log('进入路由之前');//加载数据
    next(vm => {
      vm.selectinfo();
    })
  },
  beforeRouteLeave: (to, from, next) => {
    console.log('进入路由之后');
    next()
  },
  methods:{
    add:function (){
      this.$router.push('/IaddIdentifyResult');
    },
    selectinfo:function (){
      this.loading=false;
      this.userinfo='';
      this.axios({
        method:"post",
        headers: { 'content-type': 'application/json' },
        url: "http://evidence.frogking.cn/identifyUserController/selectIdentifyResultByJid",
        params:{
          token:localStorage.getItem("token_only"),
        }
      }).then(res=>{
        console.log(res)
        if(res["data"]["code"]==='306'){
          this.info1=res["data"]["item"];
        }
        else if(res["data"]["code"]==='307'){
          this.$alert('该报表不存在', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.userinfo="";
            }
          });
        }
        else if(res["data"]["code"]==='310'){
          this.$alert('系统异常', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.userinfo="";
            }
          });
        }
        else if(res["data"]["code"]==='000'){
          this.$alert('token失效', '错误提示', {
            confirmButtonText: '确定',
            callback: action => {
              this.$router.push("/login");
              localStorage.removeItem("token_only");
            }
          });
        }
        else if(res["data"]["code"]==='001'){
          this.$alert('身份不满足，禁止操作', '错误提示', {
            confirmButtonText: '确定'
          });
        }
        else if(res["data"]["code"]==='002'){
          this.$alert('权限不满足，禁止操作', '错误提示', {
            confirmButtonText: '确定'
          });
        }
      }).catch(function (error) {
        console.log(error);
      });
    },
    select:function (){
      if(this.radio1==='报表编号'){
        this.axios({
          method:"post",
          headers: { 'content-type': 'application/json' },
          url: "http://evidence.frogking.cn/identifyUserController/selectIdentifyResultByBid",
          params:{
            token:localStorage.getItem("token_only"),
            bid:this.userinfo
          }
        }).then(res=>{
          console.log(res)
          if(res["data"]["code"]==='306'){
            this.info1=[res["data"]["item"]];
          }
          else if(res["data"]["code"]==='307'){
            this.$alert('该报表不存在', '错误提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.userinfo="";
              }
            });
          }
          else if(res["data"]["code"]==='000'){
            this.$alert('token失效', '错误提示', {
              confirmButtonText: '确定',
              callback: action => {
                this.$router.push("/login");
                localStorage.removeItem("token_only");
              }
            });
          }
          else if(res["data"]["code"]==='001'){
            this.$alert('身份不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
          else if(res["data"]["code"]==='002'){
            this.$alert('权限不满足，禁止操作', '错误提示', {
              confirmButtonText: '确定'
            });
          }
        }).catch(function (error) {
          console.log(error);
        });
      }
    },
  }
}
</script>

<style scoped>
</style>
